using System;
using System.Collections.Specialized;
using Be.Timvw.Framework.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Web.Tests.UriHelper
{
    [TestClass]
    public class WhenAddingWithCombineBehavior
    {
        [TestMethod]
        public void ShouldReturnOriginalUriAppendNewParameters()
        {
            Uri originalUri = new Uri("http://www.example.com/path/?key1=val1&key2=val2#scoobiedoe");

            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("key1", "newval");
            parameters.Add("key3", "val3");

            Uri expected = new Uri("http://www.example.com/path/?key1=val1&key1=newval&key2=val2&key3=val3#scoobiedoe");

            Uri actual = Web.UriHelper.AddParameters(originalUri, parameters, DuplicateKeyBehavior.Combine);
            Assert.AreEqual(expected, actual);
        }
    }
}